<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>zhuce</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="./jquery-3.1.1.min.js" type="text/javascript"></script>
    </head>
    <body>
        昵称:<input type="text" name="user"/><span id="span1"></span><br/>
        密码:<input type="password" name="pwd"/><span id="span2"></span><br/>
        <input type="button" name="button" value="提交"/><br/>
        <script type="text/javascript">
            {literal}
            $("input[name=button]").click(function(){
               var name=$("input[name=user]").val();
               var pwd=$("input[name=pwd]").val();
               if(name==""){
                  $("#span1").css("color","red");
                  $("#span1").html("昵称不能为空");
               }else if(pwd==""){
                   $("#span1").html("");
                  $("#span2").css("color","red");
                  $("#span2").html("密码不能为空");
               }else{
                   $.ajax({
                      type:"post",
                      url:"index.php?m=User&c=User&a=adduser",
                      data:{name:name,pwd:pwd},
                      success:function(a){
                          if(a==true){
                              window.location.href ="index.php?m=User&c=User&a=denglu"; 
                          }else{
                              alert("注册失败");
                          }
                      }
                   });
               }
            });
            {/literal}
        </script>
    </body>
</html>
